#include <supportfuncs.h>
#include <QImage>


const uint CSupportFuncs::COLORS_TABLE[16] = 
{ 
	0xff000000, 0xff000000, 0xff21C842, 0xff5EDC78, 0xff5455ED, 0xff7D76FC, 0xffD4524D, 0xff42EBF5, 
	0xffFC5554, 0xffFF7978, 0xffD4C154, 0xffE6CE80, 0xff21B03B, 0xffC95BBA, 0xffCCCCCC, 0xffFFFFFF
};


void CSupportFuncs::SetPixelRect( QImage *pImage, int x, int y, unsigned int color, int w, int h )
{
	int r, s;
	QRgb *pPixel;
	
	
	for( s = y; s < y+h; s++ )
	{
		for( r = x, pPixel = ( (QRgb*)pImage->scanLine( s ) + x  ) ; r < x+w; r++, pPixel++ )
		{
			*pPixel = color;
		}
	}

}


void CSupportFuncs::SetBorderImage( QImage *pImage, int x, int y, int w, int h, int color )
{
	int i;
	

	for( i = x - 1; i < x + w + 1; i++ )
	{
		if( i < 0 || i >= pImage->width() || ( y - 1 ) < 0 || ( y + h ) >= pImage->height() ) continue;

		pImage->setPixel( i, y - 1, color );
		pImage->setPixel( i, y + h, color );
	}
	
	for( i = y -1; i < y + h+ 1; i++ )
	{
		if( ( x -1 ) < 0 || ( x - 1 ) >= pImage->width() || i < 0 || i >= pImage->height() ) continue;

		pImage->setPixel( x - 1, i, color );
		pImage->setPixel( x + w, i, color );
	}

	
}

